package com.hl.controller;

import com.hl.domain.Heartessay;
import com.hl.domain.Heartexpert;
import com.hl.service.serviceImpl.HeartEssayImpl;
import com.hl.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//心理文章
@RequestMapping("/heartEssay")
@RestController
public class HeartEssayController {
    @Autowired
    private HeartEssayImpl heartEssayImpl;

    @GetMapping("/selectAllEssay")
    public R selectAllEssay(){
        return R.success(heartEssayImpl.selectAllEssay());
    }
    @GetMapping("/selectById")
    public R selectById(Long id){
        return R.success(heartEssayImpl.selectByIdEssay(id));
    }

    @GetMapping("/selectLikeEssay")
    public R selectLikeEssay(String title){
        return R.success(heartEssayImpl.selectLikeByEssay(title));
    }

    //    新增
    @PostMapping("/insert")
    public R insert (Heartessay heartessay){
        return R.success(heartEssayImpl.insert(heartessay));
    }
    //    删除
    @DeleteMapping("/delete")
    public R delete(Long id){
        return R.success(heartEssayImpl.delete(id));
    }

    //    修改
    @PostMapping("/update")
    public R update(Heartessay heartessay){
        return R.success(heartEssayImpl.update(heartessay));
    }


}
